#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Last Update:

'''docstring
'''

__revision__ = '0.1'
__author__ = 'lxd'

class FormatTable(object):
    def __init__(self, word):
        self.word = word

    def process(self):
        self.fetchTitleBeforeTable()
        self.setTableStyle()
        self.delBlankRows()

    def fetchTitleBeforeTable(self):
        self.word.setMouseBeforeTable()
        title = self.word.getCellText(0, 0)
        self.word.insertWordAndSetStyle(title, u'dt_3级标题')
        self.word.delRow(0)

    def setTableStyle(self):
        self.word.setFont(self.word.table)
        #column name
        self.word.selectRow(0)
        self.word.setFont(self.word.getSelection(), bold = True)
        self.word.setCenter(self.word.getSelection())

        self.word.setBorder(self.word.table.Range.Cells)

        self.word.autoFit()
        self.word.headingFormat()

    def delBlankRows(self):
        rows = self.word.table.Rows.Count
        for i in range(rows):
            if self.word.isBlankRow(i):
                self.word.delRow(i)

if __name__ == '__main__':
    pass

